<?php
/**
 * Welcome
 *
 * Shows a simple welcome message
 *
 * @package		MicroMVC
 * @author		David Pennington
 * @copyright	Copyright (c) 2008 CodeXplorer
 * @license		http://www.gnu.org/licenses/gpl-3.0.html
 * @link		http://codexplorer.com
 * @version		1.0.0 <8/15/2008>
 ********************************** 80 Columns *********************************
 */
class twitter extends core {
	
	function __construct($config=null) {
		
		//Load the core constructor
		parent::__construct($config);
		
		//Set my Username and password
		$options = array(
			'username'	=> 'username',
			'password'	=> 'password',
			'type'		=> 'json'
		);
		
		//Load the Twitter Lib as each function here will need it!
		$this->load('twitter_api', null, $options, 'libraries');
		
		//$this->twitter_api->setup($options);
		
	}
	
	//Show how many times I can query the site again?
	function index() {
	
		$object = $this->twitter_api->rate_limit_status();
		
		if(!$object) {
			$object = $this->twitter_api->response_info;
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function public_timeline() {
	
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->public_timeline()), true);
		
	}
	
	//Show how many times I can query the site again
	function friends_timeline() {
	
		$options = array('count' => 5, 'since_id' => '934576611');
		$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->friends_timeline($options)), true);
		
	}
	
	
	//Show how many times I can query the site again
	function user_timeline() {
	
		$options = array('id' => '15761650', 'count' => 30);
		$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->user_timeline($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function show() {
	
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->show('455')), true);
		
	}
	
	//Show how many times I can query the site again
	function update() {
	
		$options = array(
		'status' => 'another one'
		);
		
		$object = $this->twitter_api->update($options);
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function replies() {
	
		$options = array('since_id' => '15761650', 'page' => 2);
		$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->replies($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function friends() {
	
		$options = array('id' => '14413071');
		//$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->friends($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function followers() {
	
		$options = array('id' => '14413071');
		$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->followers($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function show_user() {
	
		$options = array('id' => '14255385');
		$options = array('id' => 'Alxandr');
		//$options = array('email' => 'david@xeoncross.com');
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->show_user($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function direct_messages() {
	
		$options = array('id' => '14255385');
		$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->direct_messages($options)), true);
		
	}
	
	
	//Show how many times I can query the site again
	function sent_messages() {
	
		$options = array('since_id' => '37156152');
		$options = null;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->sent_messages($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function new_message() {

		$options = array(
		//'user' => '16473381',
		'user' => 'david_bot',
		'text' => 'More testing of the message system. Message ID: '. rand(2, 100)
		);
		//$options = null;
		print $options['text']. '<br />';
		
		$object = $this->twitter_api->new_message($options);
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}

	
	//Show how many times I can query the site again
	function destroy_message() {

		
		$object = $this->twitter_api->destroy_message('37174704');
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	

	
	//Show how many times I can query the site again
	function tinyurl() {

		
		$object = $this->twitter_api->tinyurl('http://xeoncross.com');
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}

	
	//Show how many times I can query the site again
	function verify_credentials() {

		
		$object = $this->twitter_api->verify_credentials();
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function end_session() {

		
		$object = $this->twitter_api->end_session();
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	

	//Show how many times I can query the site again
	function update_location() {

		
		$object = $this->twitter_api->update_location('Localhost');
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	

	
	//Show how many times I can query the site again
	function friend_exists() {

		$options = array(
			'user_a' => 'david_bot',
			'user_b' => 'xeoncross'
		);
		
		$object = $this->twitter_api->friend_exists($options);
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function destroy_friend() {

		$object = $this->twitter_api->destroy_friend('david_bot');
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function create_friend() {

		$options = array(
		'id' => 'david_bot',
		'follow' => 'true'
		);
		
		$object = $this->twitter_api->create_friend($options);
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	
	//Show how many times I can query the site again
	function follow() {

		
		$object = $this->twitter_api->follow('david_bot');
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function leave() {

		
		$object = $this->twitter_api->leave('david_bot');
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function favorites() {

		$options = array(
		'page' => 1,
		'id' => 'amuse'
		);
		//$this->twitter_api->type = 'xml';
		
		$object = $this->twitter_api->favorites($options);
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function test() {

		
		$object = $this->twitter_api->test();
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function downtime_schedule() {

		
		$object = $this->twitter_api->downtime_schedule();
		
		if(!$object) {
			$object = $this->twitter_api->error();
		}
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $object), true);
		
	}
	
	//Show how many times I can query the site again
	function search() {
	
		$options['q'] = 'Awesome God';
		$options['lang'] = 'en';
		$options['rpp'] = 3;
		
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->search($options)), true);
		
	}
	
	//Show how many times I can query the site again
	function trends() {
	
		//Query the API
		$this->data['content'] = $this->view('twitter/print_r', 
			array('object' => $this->twitter_api->trends()), true);
		
	}
	//Show an example hook
	function hooks() {
	
		//Call a function from a hook
		$this->data['content'] = $this->call_hook('my_first_hook', true);
		
		//Call two class methods from a hook
		$this->data['content'] .= $this->call_hook('my_second_hook', 'MY_WORD');
		
	}

}